-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.4] Refactor pivot fix for PHP7.2 #20336
Conversation
if (! is_null($ids = $this->parseIds($ids))) { | ||
if (count((array) $ids) === 0) { | ||
if (! is_null($ids)) { | ||
$ids = $this->parseIds($ids); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 The only change of behavior here is for the case where you'd pass a Model instance that isn't saved yet (thus id = null).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm... let me check.
What would a failing test for that look like? Would be good to capture it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that because your saying inside parseIds()
that $value->getKey()
might return null
itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about use empty
instead of count
? Need to test if not gonna break
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmsantos - nice idea - that would work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@laurencei Yep that's exactly it however IMO that seems more like a bug than a feature so the change shouldn't matter... 😄
I think it makes more sense to keep
parseIds()
as anarray
return (as it was 15mins ago before #20330) - and instead just remove all the casting that was occuring throughout the function.i.e. every time
parseIds()
was called - it was being cast toarray
- so we might as well just honor the original docblock intention and fix the bug inparseIds()
itself.This also solves the
count()
issue for PHP7.2, so that you only ever count anarray
, and still honors thenull
returns for$ids
if that situation occurs.All tests pass green pre/post this change.